package com.sbwebsocket.core.service;

import com.sbwebsocket.core.model.bo.DirectMessageBody;
import com.sbwebsocket.core.model.bo.FanoutMessageBody;
import com.sbwebsocket.core.model.bo.NormalMessageBody;
import com.sbwebsocket.core.model.bo.TopicMessageBody;
import com.sbwebsocket.core.redis.RedisDirectMessageQueue;
import com.sbwebsocket.core.redis.RedisFanoutMessageQueue;
import com.sbwebsocket.core.redis.RedisTopicMessageQueue;

/**
 * @Auther: GSJ
 * @Date: 2022/2/10
 * @Description:
 * @version: 1.0
 */
public abstract class AbstractMessageQueueAdapter  implements MessageQueueAdapter {

    @Override
    public MessageQueue get(NormalMessageBody message) {
        if(message instanceof DirectMessageBody){
            return directRedisMessageQueue();
        }else if(message instanceof FanoutMessageBody){
            return fanoutRedisMessageQueue();
        }else if(message instanceof TopicMessageBody){
            return topicRedisMessageQueue();
        }

        throw new UnsupportedOperationException("暂不支持Message对应的queue实现！");
    }

    public abstract RedisDirectMessageQueue directRedisMessageQueue();

    public abstract RedisFanoutMessageQueue fanoutRedisMessageQueue();

    public abstract RedisTopicMessageQueue topicRedisMessageQueue();


}
